from mod_python import apache
from yahoo.search.web import WebSearch

def handler(req):
    req.log_error('handler')
    req.content_type = 'text/html'
    req.send_http_header()
    srch = WebSearch("YahooDemo", query='pardus')
    data = srch.parse_results()
    req.write(header % "pardus")
    for result in data.results:
        req.write('<a href="%s">%s</a> <br>\n' % (result['Url'],result['Title']))
    req.write(footer)
    return apache.OK

header = """<html>
<head>
    <title>Kontext Search Result for %s</title>
</head>
<html>
    <body>
"""

footer = """</body>
</html>
"""
